package ru.aslanov.schedule.client;

import com.smartgwt.client.data.Record;
import ru.aslanov.schedule.client.ds.InputLangProvider;

/**
 * Created by IntelliJ IDEA.
 * Created: Mar 3, 2010 5:42:41 PM
 *
 * @author Sergey Aslanov
 */
public class ScheduleUser implements InputLangProvider {
    private UserData user;
    private boolean isScheduleAdmin;
    private String currentTeacherKey;
    private String inputLang;
    private String scheduleKey;

    public ScheduleUser(UserData user, Record scheduleRecord) {
        this.user = user;
        setFromRecord(scheduleRecord);
    }

    private void setFromRecord(Record scheduleRecord) {
        this.scheduleKey = scheduleRecord.getAttribute("encodedKey");
        this.isScheduleAdmin = scheduleRecord.getAttributeAsBoolean("isScheduleAdmin");
        this.currentTeacherKey = scheduleRecord.getAttribute("teacherKey");
        this.inputLang = scheduleRecord.getAttribute("defaultInputLanguage");
    }

    public UserData getUser() {
        return user;
    }

    public boolean isScheduleAdmin() {
        return isScheduleAdmin;
    }

    public String getCurrentTeacherKey() {
        return currentTeacherKey;
    }

    public boolean isAdmin() {
        return user.isAdmin();
    }

    public String getEmail() {
        return user.getEmail();
    }

    public void setInputLang(String inputLang) {
        this.inputLang = inputLang;
    }

    public String getInputLang() {
        return inputLang;
    }

    public String getScheduleKey() {
        return scheduleKey;
    }
}
